#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll POW(ll a, ll b) {
	ll tmp=a;
	ll res=1;
	while (b) {
		if (b&1) {
			res=(res*tmp)%MOD;
		}
		tmp=(tmp*tmp)%MOD;
		b=b>>1;
	}
	return res;
}
int main() {
	int T;
//	freopen("in1.txt", "r", stdin);
	cin>>T;
	ll p,q,k;
	while (T--) {
		cin>>p>>q>>k;
		ll res=0;
		for (ll i=0; i<=k; i+=2) {
			res=(res+POW(q,i)*POW(p-q,k-i)%MOD)%MOD;
		}
		res=res*POW(POW(p,k), MOD-2)%MOD;
		cout<<res<<endl;
	}
	return 0;
} 
